import { Node, UITransform, Vec2, Vec3 } from "cc";
import Singleton from "../../../framework/base/Singleton";
import { ContainerUI } from "./ContainerUI";
import { DragData } from "./DragItem";
import { InventoryData } from "./InventoryData";
import { RectContainsPoint } from "./RectUtil";

export class InventoryManager extends Singleton {

    actionData: InventoryData

    inventoryData: InventoryData

    equipmentData: InventoryData

    actionUI: ContainerUI

    inventoryUI: ContainerUI

    equipmentUI: ContainerUI

    dragCanvas: Node

    currentDrag: DragData

    static get Instance() {
        return super.GetInstance<InventoryManager>()
    }

    public init() {
        this.actionUI.RefreshUI()
        this.inventoryUI.RefreshUI()
        this.equipmentUI.RefreshUI()
    }

    public CheckInInventoryUI = (position: Vec2) => {
        for (let i = 0; i < this.inventoryUI.slotHolders.length; i++) {
            // 判断当前位置是否物品栏
            // let t = this.inventoryUI.slotHolders[i].getComponent(UITransform)
            // if(RectContainsPoint(t, position)) {
            //     return true;
            // }
        }
        return false;
    }

    public CheckInActionUI = (position: Vec2) => {
        for (let i = 0; i < this.actionUI.slotHolders.length; i++) {
            // 判断当前位置是否物品栏
            // let t = this.inventoryUI.slotHolders[i].getComponent(UITransform)
            // if(RectContainsPoint(t, position)) {
            //     return true;
            // }
        }
        return false;
    }

    public CheckInEquipmentUI = (position: Vec2) => {
        for (let i = 0; i < this.equipmentUI.slotHolders.length; i++) {
            // 判断当前位置是否物品栏
            // let t = this.inventoryUI.slotHolders[i].getComponent(UITransform)
            // if(RectContainsPoint(t, position)) {
            //     return true;
            // }
        }
        return false;
    }

}